//
//  LocationManager.swift
//  Kosspot
//
//  Created by 李鑫 on 2025/7/9.
//

import AMapLocationKit

class LocationService: NSObject, ObservableObject {
    @Published var coordinate: CLLocationCoordinate2D?
    private let manager = AMapLocationManager()
    
    override init() {
        super.init()
        manager.delegate = self
        manager.desiredAccuracy = kCLLocationAccuracyHundredMeters
        manager.locationTimeout = 5
    }
    
    func startTracking() {
        manager.startUpdatingLocation()
    }
}

extension LocationService: AMapLocationManagerDelegate {
    func amapLocationManager(_ manager: AMapLocationManager, didUpdate location: CLLocation) {
        coordinate = location.coordinate
    }
}
